# Task 1
# Ask in the terminal 3 questions:
# year of birth
# month of birth
# day of birth
# If year is less than 1900 or greater than 2021, print "Input Error", and ask again until it's correct
# If month is less than 1 or greater than 12, print "Input Error", and ask again until it's correct
# If month is less than 1 or greater than 31, print "Input Error", and ask again until it's correct
# print his or her birthday in the terminal like "Your birthday is 2010-03-03"
# Note: the "0" shouldn't be omitted in "03"

total_input_errors = 0  # 用于计数输入错误的总数，在输入错误时会+=1
while True:  # 只要不break，就先保持在这个循环里
    year_of_birth = int(input("year of birth: "))  # 设置year of birth
    if year_of_birth < 1900 or year_of_birth > 2021:  # 如果在1900年以前或者2021年以后，输出
        print("Input Error")
        total_input_errors += 1  # 计数输入错误的总数
        if total_input_errors > 3:  # 如果错误超过三次
            print("Are you serious?")
            break  # 退出该while循环
    else:  # 如果输入的值在1900-2021年间
        break  # 退出该while循环
if total_input_errors <= 3:  # 如果输入错误小于等于3次再继续
    while True:
        month_of_birth = int(input("month of birth: "))
        if month_of_birth < 1 or month_of_birth > 12:
            print("Input Error")
            total_input_errors += 1
            if total_input_errors > 3:
                print("Are you serious?")
                break
        else:
            break
if total_input_errors <= 3:  # 如果输入错误小于等于3次再继续
    while True:
        day_of_birth = int(input("day of birth: "))
        if day_of_birth < 1 or day_of_birth > 31:
            print("Input Error")
            if total_input_errors > 3:
                print("Are you serious?")
                break
            total_input_errors += 1
        else:
            break
if total_input_errors <= 3:  # 如果输入错误小于等于3次再继续
    str_month = f"{month_of_birth}"  # month_of_birth转换成str，储存在str_month这个变量里
    str_day = f"{day_of_birth}"
    if month_of_birth < 10:  # 如果month_of_birth这个int小于10，需要在str_month这个字符串前补上"0"
        str_month = "0" + str_month
    if day_of_birth < 10:  # 如果day_of_birth这个int小于10，需要在str_day这个字符串前补上"0"
        str_day = "0" + str_day
    print(f"Your birthday is {year_of_birth}-{str_month}-{str_day}")


# Task 2
# Using the existing program.
# If there are totally more than 3 times of "Input Error"s, print "Are you serious?" and then quit the program.
